<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="./js/jquery-2.1.1.js"></script>
    <script src="./js/underscore.js"></script>
    <script src="./js/backbone.js"></script>
</head>
<body>
hello backbone

<script>
    var AppRouter = Backbone.Router.extend({
        routes: {
            "posts/:id": "getPost",
            // <a href="http://example.com/#/posts/121">Example</a>

            "download/*path": "downloadFile",
            // <a href="http://example.com/#/download/user/images/hey.gif">Download</a>

            ":route/:action": "loadView",
            // <a href="http://example.com/#/dashboard/graph">Load Route/Action View</a>

            "*actions": "defaultRoute"// matches http://example.com/#anything-here
            // Backbone will try match the route above first
        }
    });
    // Initiate the router
    var app_router = new AppRouter;

    app_router.on('route:getPost', function (id) {
        console.log("route:getPost "+id); // 121
    });

    app_router.on('route:downloadFile', function (path) {
        console.log("route:downloadFile "+path); // user/images/hey.gif
    });
    app_router.on('route:loadView', function (route, action) {
        console.log("route:loadView "+route + " " + action); // dashboard_graph
    });

    app_router.on('route:defaultRoute', function (actions) {
        console.log("route:defaultRoute "+actions);
    })

    // Start Backbone history a necessary step for bookmarkable URL's
    Backbone.history.start();
</script>

</body>
</html>